export default{
    formatDate:function(date, fmt) {
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
        }
        var o = {
            'M+': date.getMonth() + 1,
            'd+': date.getDate(),
            'h+': date.getHours(),
            'm+': date.getMinutes(),
            's+': date.getSeconds()
        };
        for (var k in o) {
            if (new RegExp('('+k+')').test(fmt)) {
                var str = o[k] + '';
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00'+str).substr(str.length));
            }
        }
        return fmt;
    },
    //用户没有登录时进入个别页面时跳转至登录页
    goToLogin:function(){
    	if(this.cookie.getCookie('ticket')==null||this.cookie.getCookie('ticket')==undefined||this.cookie.getCookie('ticket')==''){
    	    this.$router.push('login');
            return false;
    	}else{
            var authType=this.cookie.getCookie('login_auth_type');
            var loginAuthToken=this.cookie.getCookie('login_auth_token');
            if(authType==1) {
                if (loginAuthToken == null || loginAuthToken == undefined || loginAuthToken == '') {
                    this.$router.push('securityCode');
                    return false;
                } else {
                    return true;
                }
            }else {
                return true;
            }
        }
    }
    ,
    toMoneySercurity:function () {
        var authType=this.cookie.getCookie('money_auth_type');
        var moneyAuthToken=this.cookie.getCookie('money_auth_token');
        if(authType==1) {
            if (moneyAuthToken == null || moneyAuthToken == undefined || moneyAuthToken == '') {
                this.$router.push('securityMoneyCode');
                return false;
            } else {
                return true;
            }
        }else {
            return true;
        }
    }
}
